/*
 * BTServiceListener.java
 *
 * Created on 2 September 2007, 12:51
 *
 */

package digitrix.network.bt;

import java.util.Enumeration;
import java.util.Vector;
import javax.bluetooth.DataElement;
import javax.bluetooth.DeviceClass;
import javax.bluetooth.DiscoveryListener;
import javax.bluetooth.RemoteDevice;
import javax.bluetooth.ServiceRecord;

/**
 *
 * @author Josh
 */
public class BTServiceListener implements DiscoveryListener {
    
    private BTManager _btManager = null;
    private Vector _foundServiceRecords; 
    
    /** Creates a new instance of BTServiceListener */
    public BTServiceListener( BTManager btManager ) {
        _btManager = btManager;
        _foundServiceRecords = new Vector(); 
    }
    
    public void servicesDiscovered( int transID, ServiceRecord[] servRecord ){        
        DataElement sn; // for service name (player name)
        
        _foundServiceRecords.addElement( servRecord[0] );
    }
    
    public void serviceSearchCompleted( int transID, int respCode ){
        synchronized( this ){
            this.notifyAll();
        }
    }
    
    public void deviceDiscovered( RemoteDevice btDevice, DeviceClass cod){}
    
    public void inquiryCompleted(int dicType ){}
    
    public Enumeration getFoundServiceRecords(){
        return _foundServiceRecords.elements(); 
    }
    
    public Vector getFoundServiceRecordsVector(){
        return _foundServiceRecords; 
    }
    
}
